# !/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time        : 2021/10/16 13:33
@Author      : Albert Darren
@Contact     : 2563491540@qq.com
@File        : filter_compair.py
@Version     : Version 1.0.0
@Description : TODO
@Created By  : PyCharm
"""
from PIL import ImageFilter, Image
from DIP_experiment_5.util import contrast_show

im_path = "../experiment_fig/sakura.jpg"
font_path = "C:/Windows/Fonts/simhei.ttf"
im = Image.open(im_path)
r, g, b = im.split()
# 高斯滤波
three_gaussion_blur_im = r.filter(ImageFilter.GaussianBlur(radius=3))
five_gaussion_blur_im = r.filter(ImageFilter.GaussianBlur(radius=5))
seven_gaussion_blur_im = r.filter(ImageFilter.GaussianBlur(radius=7))
nine_gaussion_blur_im = r.filter(ImageFilter.GaussianBlur(radius=9))
im_dict = {"原始图像": im, "r通道灰度图": r, "3x3卷积核高斯滤波": three_gaussion_blur_im,
           "5x5卷积核高斯滤波": five_gaussion_blur_im, "7x7卷积核高斯滤波": seven_gaussion_blur_im,
           "9x9卷积核高斯滤波":nine_gaussion_blur_im}
contrast_show(im_dict, (2, 3), hspace=0.2, font=font_path)
# # 均值滤波
# three_blur_im = r.filter(ImageFilter.Kernel(size=(3, 3), kernel=(1, 1, 1, 1, 0, 1, 1, 1, 1)))
# five_blur_im = r.filter(ImageFilter.BLUR)
# im_dict = {"原始图像": im, "r通道灰度图": r, "3x3卷积核均值滤波": three_blur_im,
#            "5x5卷积核均值滤波": five_blur_im}
# contrast_show(im_dict, (2, 2), hspace=0.4, font=font_path)
